import { Controller, Param, Post } from '@nestjs/common';
import { PointsService } from './points.service';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ModuleSwaggerTags } from '~/constants/modules.constant';
import { Public } from '../auth/decorators/public.decorator';
import { ApiTenantHeader } from '~/common/decorators/api-header-tenant.decorator';
import { AuthTenant } from '../tenant/tenant.decorator';

@ApiBearerAuth()
@ApiTags(ModuleSwaggerTags.POINTS)
@Controller()
export class PointsController {
  constructor(private readonly pointsService: PointsService) {}

	@Public()
	@Post(':id')
	@ApiOperation({ summary: '添加用户积分账户' })
	@ApiTenantHeader()
	async getPointsByUserId(@Param('id') userId: number, @AuthTenant() tenant: IAuthTenant) {
		// 调用服务层的方法
		const points = await this.pointsService.getPointsByUserId(userId);
		return points;
	}
}
